from gglib.auth import is_logged
from gglib.user import manager


class SessionMiddleware:
    def process_packet(self, session, packet, incoming):
        if incoming == True:
            if "sender" not in packet and is_logged(session):
                packet.sender = session['_user_id']
                session.user = manager[session['_user_id']]
        else:
            pass
